#include "VideoReader.hpp"
namespace Moduels::FramesIO
{
    void VideoReader::Init()
    {
        Path=Format.Root;
        Video.open(Path);
        if(!Video.isOpened())
        {
            std::cout<<"VideoReader Open Video Failed!"<<std::endl;
        }
        VideoSize=Video.get(cv::CAP_PROP_FRAME_COUNT);
        FrameIndex=0;
    }

    cv::Mat VideoReader::GetCurrentPicture()
    {
        Video.read(OriginPicture);
        if(FrameIndex ==VideoSize-1)
        {
            FrameIndex=0;
            Video.set(cv::CAP_PROP_POS_FRAMES,0);
        }
        FrameIndex++;
        return OriginPicture;
    }
}